package com.ibeeking.found.msg.api.feign;

import com.ibeeking.found.msg.api.common.dto.OssPolicyDto;
import com.ibeeking.found.msg.api.common.query.FileNameQuery;
import com.ibeeking.found.msg.api.feign.fallback.MsgFileFeignFallbackFactory;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Author ibeeking
 */
@FeignClient(name = "base-file-b-server", path = "/b", contextId = "msgOpenFileFeignClient", fallbackFactory = MsgFileFeignFallbackFactory.class, decode404 = true)
public interface MsgFileFeignClient {
    /**
     * 获取oss配置项
     *
     * @return
     */
    @GetMapping(value = "/file/feign/v1/policy")
    ResponseResult<OssPolicyDto> policy();
    /**
     * 获取文件流
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/file/feign/v1/queryFile")
    feign.Response queryFile(@RequestBody FileNameQuery query);
    /**
     * 获取文件流
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/file/feign/v1/downloadFile")
    ResponseResult<String> downloadFile(@RequestBody FileNameQuery query);
    /**
     * 获取文件流
     *
     * @param file
     * @return
     */
    @PostMapping(value = "/file/feign/v1/upload", produces = "application/json;charset=UTF-8", headers = "content-type=" + MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseResult<String> uploadFile(@RequestPart("file") MultipartFile file);

}
